package business;
import java.util.HashSet;
import java.util.Set;





/***********************************************************
 * Filename: Matricula.java
 * Created:  2009/10/20
 ***********************************************************/

/***********************************************************
 * @author FBA 2009/10/20
 * 
 ***********************************************************/
public class Matricula implements MatriculaInterface
{
    private static Set<Matricula> matriculas = new HashSet<Matricula>(12000);

    private Aluno aluno;
    private Perfil perfil;

    CalendarDate dataInscricao;
    Boolean paga = false;

    /***********************************************************
     * @return the matriculas
     ***********************************************************/
    public static Set<Matricula> objectos()
    {
    	getLogger();
	return matriculas;
	
    }

    /***********************************************************
     * 
     ***********************************************************/
     public static void reset()
     {
	 matriculas.clear();
	 getLogger();
     }
     
    /***********************************************************
     * 
     ***********************************************************/
     public Matricula()
     {
 	super();
	matriculas.add(this);
	getLogger();
     }
     
    /***********************************************************
     * @param aluno
     * @param perfil
     * @param dataInscricao
     ***********************************************************/
    public Matricula(Aluno aluno, Perfil perfil, CalendarDate dataInscricao)
    {
	this.aluno = aluno;
	this.perfil = perfil;
	this.dataInscricao = dataInscricao;
	
	matriculas.add(this);
	getLogger();
    }

    /* (non-Javadoc)
	 * @see business.MatriculaInterface#getAluno()
	 */
    public Aluno getAluno()
    {
    	getLogger();
	return aluno;
	
    }

    /* (non-Javadoc)
	 * @see business.MatriculaInterface#getPerfil()
	 */
    public Perfil getPerfil()
    {
    	getLogger();
	return perfil;
	
    }

    /* (non-Javadoc)
	 * @see business.MatriculaInterface#getDataInscricao()
	 */
    public CalendarDate getDataInscricao()
    {
    	getLogger();
	return dataInscricao;
    }

    /* (non-Javadoc)
	 * @see business.MatriculaInterface#getPaga()
	 */
    public Boolean getPaga()
    {
    	getLogger();
	return paga;
    }

    /* (non-Javadoc)
	 * @see business.MatriculaInterface#setAluno(business.Aluno)
	 */
    public void setAluno(Aluno aluno)
    {
    	getLogger();
	this.aluno = aluno;
    }
    


    /* (non-Javadoc)
	 * @see business.MatriculaInterface#setPerfil(business.Perfil)
	 */
    public void setPerfil(Perfil perfil)
    {
    	getLogger();
	this.perfil = perfil;
    }

    /* (non-Javadoc)
	 * @see business.MatriculaInterface#setDataInscricao(business.CalendarDate)
	 */
    public void setDataInscricao(CalendarDate dataInscricao)
    {
    	getLogger();
	this.dataInscricao = dataInscricao;
    }

    /* (non-Javadoc)
	 * @see business.MatriculaInterface#setPaga(java.lang.Boolean)
	 */
    public void setPaga(Boolean paga)
    {
    	getLogger();
        this.paga = paga;
    }

    /***********************************************************
	* 
	***********************************************************/
    void pagar()
    {
    	getLogger();
	paga = true;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    /* (non-Javadoc)
	 * @see business.MatriculaInterface#toString()
	 */
    @Override
    public String toString()
    {
    	getLogger();
	return "Matricula [aluno=" + aluno.getNumero() + ", perfil=" + perfil.getNome() + ", dataInscricao=" + dataInscricao + ", paga="
		+ paga + "]";
    }
    
    
    public static String getLogger() {
        final Throwable t = new Throwable();
        final StackTraceElement methodCaller = t.getStackTrace()[2];
        final String logger = methodCaller.getClassName();
        int i = logger.length();
        char c = ' ';
        while(i>=0 && c!='.'){
        	i--;
        	c = logger.charAt(i);
        	}
        i++;
    	String s = logger.substring(i);
        System.err.println(s);

        return logger;
}
}
